const express = require("express")

const app = express()

app.get('/',
    // (req, res, next) => {
    //     console.log("局部中间件")
    //     req.a = 1
    //     throw new Error("服务器内部发生错误")
    //     next()
    // }, 
    (req, res) => {
        // console.log("pages", req.a)
        throw new Error("服务器内部发生错误")
        res.send("pages" + req.a)
    })

app.use((err, req, res, next) => {
    res.send(err.message)
    console.log(err.message + "123")
})

app.listen(8080, () => {
    console.log("服务端已经启动")
})